package net.y2t72.microblog.web;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

import org.apache.log4j.PropertyConfigurator;

/**
 * log4j初始化类
 * @author Administrator
 *
 */

public class Log4jInit extends HttpServlet {

	/**
	 * 版本号
	 */
	private static final long serialVersionUID = -2145637611139484621L;

	@Override
	public void init(ServletConfig config) throws ServletException {
		//获取当前文件真实路径
		String prefix = config.getServletContext().getRealPath("/");
		//从web.xml中读取log4j配置文件的相对位置
		String file = config.getInitParameter("log4j");
		//读取配置文件
		PropertyConfigurator.configure(prefix + file);
	}
}
